package cn.good.yan.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * 账户实体
 *
 * @author shengren.yan
 * @create 2024-02-22
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "t_account")
public class Account implements Serializable {

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    /**
     * id
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 用户id
     */
    private Long userId;

    /**
     * 总额度
     */
    private Long total;

    /**
     * 已用余额
     */
    private Long used;

    /**
     * 剩余可用额度
     */
    private Long residue;

}

//    CREATE DATABASE seata_account;
//
//    CREATE TABLE t_account (
//    `id` BIGINT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT 'id',
//    `user_id` BIGINT(11) DEFAULT NULL COMMENT '用户id',
//    `total` DECIMAL(10,0) DEFAULT NULL COMMENT '总额度',
//    `used` DECIMAL(10,0) DEFAULT NULL COMMENT '已用余额',
//    `residue` DECIMAL(10,0) DEFAULT '0' COMMENT '剩余可用额度'
//    ) ENGINE=INNODB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
//
//    INSERT INTO seata_account.t_account(`id`, `user_id`, `total`, `used`, `residue`) VALUES ('1', '1', '1000', '0', '1000');
//    SELECT * FROM t_account;
